using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SnailSkillState : BaseState {
    
    public override void OnEnter(Enemy enemy) {
        Debug.Log("snail skill");
        currentEnemy = enemy;
        currentEnemy.currentSpeed = 0;
        currentEnemy.ani.SetBool("isWalk", false);
        currentEnemy.ani.SetBool("isHide", true);
        currentEnemy.ani.SetTrigger("skill");

        currentEnemy.lostTimeCounter = currentEnemy.lostTime;
        currentEnemy.GetComponent<Character>().invincible = true;
        currentEnemy.GetComponent<Character>().invincibleCounter = currentEnemy.lostTimeCounter;
    }

    public override void LogicUpdate() {
        // 如果丢失目标超过一定时间则从壳里出来，重新回到巡逻状态
        if (currentEnemy.lostTimeCounter <= 0) {
            currentEnemy.SwitchState(NPCState.Patrol);
        }

        currentEnemy.GetComponent<Character>().invincibleCounter = currentEnemy.lostTimeCounter;
    }

    public override void PhysicsUpdate() {
        
    }

    public override void OnExit() {
        currentEnemy.ani.SetBool("isHide", false);
        Debug.Log("snail skill exit");
    }

}
